package com.aspire.shiro.client;

import com.aspire.shiro.tools.DigestsUtil;
import com.aspire.shiro.tools.EncodesUtils;
import org.junit.Test;

import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Map;

/**
 * 测试编码解码
 */
public class ClientTest {

    @Test
    public void testHex() {
        String s = "admin";
        String encodeHex = EncodesUtils.encodeHex(s.getBytes());
        System.out.println(encodeHex);
        byte[] bytes = EncodesUtils.decodeHex(encodeHex);
        String b = new String(bytes);
        System.out.println(b);
        System.out.println(s.equals(b));
    }


    @Test
    public void testBase64() {
        String s = "admin";
        String encodeHex = EncodesUtils.encodeBase64(s.getBytes());
        System.out.println(encodeHex);
        byte[] bytes = EncodesUtils.decodeBase64(encodeHex);
        String b = new String(bytes);
        System.out.println(b);
        System.out.println(s.equals(b));
    }

    @Test
    public void testDigest(){
        Map<String, String> map = DigestsUtil.entryPassword("huyuzhu");
        System.out.println(map);
    }
}
